package com.lcj.crawler;

import com.geccocrawler.gecco.pipeline.Pipeline;
import com.lcj.service.CompanyRecruitInfoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class SaveCshrContact implements Pipeline<CshrContact> {

    @Resource(name="companyRecruitInfoServiceImpl")
    private CompanyRecruitInfoService companyRecruitInfoService;

    @Override
    public void process(CshrContact cshrContact) {
        String companyUrl = cshrContact.getRequest().getUrl();
        String contactPerson = cshrContact.getContactPerson();
        String address = cshrContact.getAddress();
        String email = "";
        String phone = "";
        if(cshrContact.getMobilephone()==null){
            phone = cshrContact.getEmail();
            email = cshrContact.getPhone();
        }else{
            phone = "电话"+cshrContact.getPhone()+"手机"+cshrContact.getMobilephone();
            email = cshrContact.getEmail();
        }
        companyRecruitInfoService.update(companyUrl,contactPerson,phone,email,address);
    }
}
